﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core.Service;
using PersonalHealth.Data.Model;
using PersonalHealth.Data.Data;
using PersonalHealth.Data.IService;
using Core.UnitOfWork;
using PersonalHealth.Data.Repository;

namespace PersonalHealth.Data.Service
{
    public class TaskService : Service<Task, HealthContext>, ITaskService
    {
        public IList<Task> GetUserTasks(int userid, int pageIndex, int pageCount, out int msgCount)
        {
            using (HealthContext context = new HealthContext())
            {
                IUnitOfWork unitOfWork = new UnitOfWork(context);
                ITaskRepository repository = new TaskRepository(unitOfWork);
                return repository.GetUserTasks(userid, pageIndex, pageCount, out msgCount);
            }
        }

        public IList<Task> GetUserTasks(int userid, TaskType type, int pageIndex, int pageCount, out int msgCount)
        {
            using (HealthContext context = new HealthContext())
            {
                IUnitOfWork unitOfWork = new UnitOfWork(context);
                ITaskRepository repository = new TaskRepository(unitOfWork);

                return repository.GetUserTasks(userid, type, pageIndex, pageCount, out msgCount);
            }

        }
    }
}
